<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>				  
User Roles:
<c:forEach var="role" items="${roles}">
	<p><c:if test="${role.value=='1'}">
		<input type="checkbox" name="checkboxrole[]" id="checkboxrole${role.key.id}"  checked="checked" value="${role.key.id}"/> 

	</c:if>		
	<c:if test="${role.value=='0'}"> 
		<input type="checkbox" name="checkboxrole[]"  id="checkboxrole${role.key.id}" value="${role.key.id}"/> 
	</c:if>	
	<label for="checkboxrole${role.key.id}">${role.key.name}</label>						  
	</p>
</c:forEach>
				<P>
						<input type="button" id="saveUserRole" value="保存" class="button_selector" />
				</P>
<script type="text/javascript">	
$(document).ready(function() {
	$("#saveUserRole").button();
	
	$("#saveUserRole").click(function() {
		saveUserRole();
	})	
	
	function saveUserRole() {
		var ids = new Array();
		$("input[name='checkboxrole[]']:checked").each(function() {
			ids.push($(this).val());
		});
		$.ajax({
			url : '/ifinance/user/saveUserRole.html',
			type : 'POST',
			data : 'id=' + $('#id').val() + '&ids=' + ids,
			//dataType : 'json',
			success : function(xht, status) {
				//alert("保存成功 : " + xht);
				$('#tabs-1').html(xht);
			},
			error : function(xht, status) {
				alert("保存出错 : " + xht);
			}
		});
		return true;
	}			
});	
</script>
